package command;

/**
 * 以计算器命令做场景说明
 */
public class Invoker {

    Command command;

    public void setCommand(Command command) {
        this.command = command;
    }

    //计算
    public void compute(int value) {
        int result = command.execute(value);
        System.out.println("计算成功, result = " + result);
    }


    //撤销
    public void undo() {
        int result = command.reset();
        System.out.println("撤销成功, result = " + result);
    }

}
